﻿<!--
    ErrorProviders is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    ErrorProviders is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with ErrorProviders; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    -->
    
    <Window x:Class="DemoApp.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    
    <Window.Resources>
        <LinearGradientBrush x:Key="LightBrush" StartPoint="0,0" EndPoint="0,1">
            <GradientBrush.GradientStops>
                <GradientStopCollection>
                    <GradientStop Color="#FFF" Offset="0.0"/>
                    <GradientStop Color="#EEE" Offset="1.0"/>
                </GradientStopCollection>
            </GradientBrush.GradientStops>
        </LinearGradientBrush>
        <SolidColorBrush x:Key="SolidBorderBrush" Color="#888" />

        <Style x:Key="{x:Type ToolTip}" TargetType="ToolTip">
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="HasDropShadow" Value="True"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ToolTip">
                        <Border Name="Border"
          Background="{StaticResource LightBrush}"
          BorderBrush="{StaticResource SolidBorderBrush}"
          BorderThickness="1"
          Width="{TemplateBinding Width}"
          Height="{TemplateBinding Height}">
                            <ContentPresenter
            Margin="4" 
            HorizontalAlignment="Left"
            VerticalAlignment="Top" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="HasDropShadow" Value="true">
                                <Setter TargetName="Border" Property="CornerRadius" Value="4"/>
                                <Setter TargetName="Border" Property="SnapsToDevicePixels" Value="true"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

    </Window.Resources>
    
    <StackPanelErrorProvider x:Name="errorProvider" ErrorMessage="Invalid data" ErrorPropertyModified="Background" ErrorValue="Red" >
        
        <!--<Grid.ColumnDefinitions>
            <ColumnDefinition Width="100" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        
        <Grid.RowDefinitions>
            <RowDefinition Height="25" />
            <RowDefinition Height="25" />
            <RowDefinition Height="*" />
            <RowDefinition Height="25" />
        </Grid.RowDefinitions>-->
        
        <TextBlock Text="Username"  />
        <TextBox x:Name="textboxUserName" StackPanelErrorProvider.ErrorPropertyModified="Style" />
        
        <TextBlock Text="Password"  />
        <PasswordBox x:Name="passwordBox" StackPanelErrorProvider.ErrorMessage="Incorrect password" />
        
        <StackPanel Orientation="Horizontal" >
            <TextBlock Text="In stackpanel" Height="25" ></TextBlock>
            <ComboBox Height="25" >
                <ComboBoxItem>1</ComboBoxItem>
                <ComboBoxItem>2</ComboBoxItem>
                <ComboBoxItem>3</ComboBoxItem>
            </ComboBox>
        </StackPanel>
        
        <Button Content="Validate !" Click="Button_Click" />
        
    </StackPanelErrorProvider>
</Window>
